package vip.xiaonuo.bi.modular.dataset.config;

import com.baomidou.dynamic.datasource.provider.DynamicDataSourceProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.sql.DataSource;

/**
 * @auther: 顾育司
 * @Description
 * @date: 2024/1/9
 */

@Configuration
public class DorisConfig {

    @Autowired
    @Qualifier("ymlDynamicDataSourceProvider")
    private DynamicDataSourceProvider dynamicDataSourceProvider;


    //获取当前数据源
    @Bean(name = "dorisJdbcTemplate")
    public JdbcTemplate dorisJdbcTemplate() {
        DataSource dataSource = dynamicDataSourceProvider.loadDataSources().get("doris");
        return new JdbcTemplate(dataSource);
    }

}
